package com.medusa.aps.business.modules.modeling.mp.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.medusa.aps.business.model.BaseEntity;
import com.medusa.aps.business.model.enums.SourceEnum;
import com.medusa.aps.business.modules.modeling.model.output.BomVo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;

/**
 * bom表
 *
 * @author miskw
 * @date 2023/8/23
 */
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
public class Bom extends BaseEntity<Bom> {
    /**
     * 主键
     */
    @TableId(type = IdType.AUTO)
    @Schema(description = "BOM id")
    private Integer id;
    /**
     * bom编码
     */
    @Schema(description = "bom编码")
    private String bomCode;
    /**
     * bom名称
     */
    @Schema(description = "bom名称")
    private String bomName;
    /**
     * 物料id
     */
    @Schema(description = "物料id")
    private Long materialId;
    /**
     * 物料编码
     */
    @Schema(description = "物料编码")
    private String materialCode;
    /**
     * 物料名称
     */
    @Schema(description = "物料名称")
    private String materialName;
    /**
     * 创建人
     */
    @Schema(description = "创建人")
    @TableField(fill = FieldFill.INSERT)
    private String creator;
    /**
     * 数据来源
     */
    @Schema(description = "数据来源")
    private SourceEnum dataSource;

    public BomVo toBomVo() {
        return new BomVo()
                .setId(id)
                .setBomCode(bomCode)
                .setBomName(bomName)
                .setMaterialId(materialId)
                .setMaterialCode(materialCode)
                .setMaterialName(materialName);

    }

    @Override
    public Serializable pkVal() {
        return super.pkVal();
    }
}
